package ganga.custodian;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * Обработчик события загрузки ОС
 * запускает сервис CustodianService 
 * @see http://www.androidenea.com/2009/09/starting-android-service-after-boot.html
 * http://code.google.com/p/android-bluetooth-on-motion/source/browse/trunk/BluetoothOnMotion/src/com/elsewhat/android/onmotion/BootReceiver.java
 * @author Apocrypha
 *
 */
public class OnBootReceiver extends BroadcastReceiver {

	@Override
	public void onReceive(Context context, Intent intent) {
		if ("android.intent.action.BOOT_COMPLETED".equals(intent.getAction())) {
			//TODO: Прочитать сохранённую настройку автозапуска 
			context.startService(new Intent(context, CustodianService.class));
			Log.v(this.getClass().getName(), "Custodian service started while device boot.");
		}
	}
}